Skip to content

Persist OAuth project scope - #216

Open
masnwilliams wants to merge 7 commits into
mainfrom
hypeship/project-scoped-oauth-cli
Open

Persist OAuth project scope#216
masnwilliams wants to merge 7 commits into
mainfrom
hypeship/project-scoped-oauth-cli

Conversation

@masnwilliams

@masnwilliams masnwilliams commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

summary

  • persist authoritative organization/project scope returned by the OAuth server
  • preserve scope across automatic refresh and treat legacy credentials as organization-wide
  • show the active OAuth scope in kernel auth
  • document organization-wide and project-scoped login behavior

tests

  • go test ./...
  • go vet ./...
  • go build ./...

dependency

Pairs with kernel/kernel-mcp-server#138. The fields are optional, so this remains compatible with the currently deployed OAuth server.


Note

Medium Risk
Changes OAuth token handling and stored credential shape; behavior is backward compatible for legacy tokens but affects how scope is enforced for all OAuth sessions after login or refresh.

Overview
Adds organization-wide vs project-scoped OAuth to the CLI by persisting access_scope and project_id on stored credentials.

During login, the callback may carry scope in OAuth state; after code exchange, token response fields override state for org_id, access_scope, and project_id. Missing scope defaults to organization-wide; org-wide tokens clear project_id. The same fields are updated on refresh, with legacy tokens without scope fields treated as organization-wide.

kernel auth prints whether the session is organization-wide or locked to a project ID. README documents choosing scope at login and that project-scoped tokens cannot use --project to switch projects.

Tests cover authoritative scope from token exchange, refresh preserving project scope, and legacy refresh behavior.

Reviewed by Cursor Bugbot for commit c9eb41d. Bugbot is set up for automated code reviews on this repo. Configure here.

@masnwilliams
masnwilliams requested a review from hiroTamada August 5, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants